package mid

import (
	"sort"
)

func MinimumAddedCoins(coins []int, target int) int {
	sort.Ints(coins)
	ans := 0
	i := 0
	x := 1
	for x <= target {
		if i < len(coins) && coins[i] <= x {
			x += coins[i]
			i++
		} else {
			x *= 2
			ans++
		}
	}
	return ans
}
